using UnityEngine;
// [Assembly-CSharp.dll].ETFXProjectileScript
public class ETFXProjectileScript : MonoBehaviour
{
    // Fields
    public UnityEngine.GameObject impactParticle;
    public UnityEngine.GameObject projectileParticle;
    public UnityEngine.GameObject muzzleParticle;
    public float colliderRadius;
    public float collideOffset;
    
    // Methods
    private void Start()
    {
        UnityEngine.Vector3 val_2 = this.transform.position;
        UnityEngine.Quaternion val_4 = this.transform.rotation;
        this.projectileParticle = UnityEngine.Object.Instantiate<System.Object>(original:  this.projectileParticle, position:  new UnityEngine.Vector3() {x = val_2.x, y = val_2.y, z = val_2.z}, rotation:  new UnityEngine.Quaternion() {x = val_4.x, y = val_4.y, z = val_4.z, w = val_4.w});
        this.projectileParticle.transform.parent = this.transform;
        if((UnityEngine.Object.op_Implicit(exists:  this.muzzleParticle)) == false)
        {
                return;
        }
        
        UnityEngine.Vector3 val_10 = this.transform.position;
        UnityEngine.Quaternion val_12 = this.transform.rotation;
        this.muzzleParticle = UnityEngine.Object.Instantiate<System.Object>(original:  this.muzzleParticle, position:  new UnityEngine.Vector3() {x = val_10.x, y = val_10.y, z = val_10.z}, rotation:  new UnityEngine.Quaternion() {x = val_12.x, y = val_12.y, z = val_12.z, w = val_12.w});
        UnityEngine.Object.Destroy(obj:  this.muzzleParticle, t:  1.5f);
    }
    private void FixedUpdate()
    {
        Unknown val_51;
        var val_52;
        float val_53;
        float val_54;
        float val_55;
        float val_56;
        UnityEngine.Object val_57;
        float val_58;
        float val_59;
        float val_60;
        float val_61;
        float val_62;
        UnityEngine.Vector3 val_2 = this.GetComponent<System.Object>().velocity;
        val_52 = 27350944;
        val_2.x = val_2.x * val_2.x;
        val_2.y = val_2.y * val_2.y;
        val_2.x = val_2.x + val_2.y;
        val_2.x = (val_2.z * val_2.z) + val_2.x;
        if(val_2.x != 0f)
        {
                UnityEngine.Vector3 val_6 = this.GetComponent<System.Object>().velocity;
            UnityEngine.Quaternion val_7 = UnityEngine.Quaternion.LookRotation(forward:  new UnityEngine.Vector3() {x = val_6.x, y = val_6.y, z = val_6.z});
            this.transform.rotation = new UnityEngine.Quaternion() {x = val_7.x, y = val_7.y, z = val_7.z, w = val_7.w};
        }
        
        if((UnityEngine.Object.op_Implicit(exists:  this.transform.GetComponent<System.Object>())) != false)
        {
                val_53 = this.transform.GetComponent<System.Object>().radius;
        }
        else
        {
                val_53 = this.colliderRadius;
        }
        
        UnityEngine.Vector3 val_16 = this.transform.GetComponent<System.Object>().velocity;
        val_54 = val_16.x;
        val_55 = val_16.y;
        val_56 = val_16.z;
        if((this.transform.GetComponent<System.Object>().useGravity) != false)
        {
                UnityEngine.Vector3 val_20 = UnityEngine.Physics.gravity;
            float val_21 = UnityEngine.Time.deltaTime;
            val_21 = val_20.z * val_21;
            val_54 = val_54 + (val_20.x * val_21);
            val_55 = val_55 + (val_20.y * val_21);
            val_56 = val_56 + val_21;
        }
        
        float val_24 = val_54 * val_54;
        val_24 = val_24 + (val_55 * val_55);
        val_24 = (val_56 * val_56) + val_24;
        if(val_24 > (1E-05f))
        {
                val_58 = val_54 / val_24;
            val_59 = val_55 / val_24;
            val_60 = val_56 / val_24;
        }
        else
        {
                val_58 = mem[mem[536895737]];
            val_58 = mem[536895737];
            val_59 = mem[mem[536895737] + 4];
            val_59 = mem[536895737] + 4;
            val_60 = mem[mem[536895737] + 8];
            val_60 = mem[536895737] + 8;
        }
        
        UnityEngine.Vector3 val_29 = this.transform.GetComponent<System.Object>().velocity;
        val_61 = val_29.z;
        float val_32 = val_29.x * val_29.x;
        val_29.y = val_29.y * val_29.y;
        val_32 = val_32 + val_29.y;
        val_32 = (val_61 * val_61) + val_32;
        val_62 = val_32 * UnityEngine.Time.deltaTime;
        UnityEngine.Vector3 val_34 = this.transform.position;
        if((UnityEngine.Physics.SphereCast(origin:  new UnityEngine.Vector3() {x = val_34.x, y = val_34.y, z = val_34.z}, radius:  val_53, direction:  new UnityEngine.Vector3() {x = val_58, y = val_59, z = val_60}, hitInfo:  new UnityEngine.RaycastHit() {m_Point = new UnityEngine.Vector3() {x = 0f, y = 0f, z = 0f}, m_Normal = new UnityEngine.Vector3() {x = 0f, y = 0f, z = 0f}, m_Distance = 0f, m_UV = new UnityEngine.Vector2() {x = 0f, y = 0f}}, maxDistance:  val_62)) == false)
        {
                return;
        }
        
        UnityEngine.Vector3 val_37 = 0.point;
        UnityEngine.Vector3 val_38 = 0.normal;
        val_38.x = val_38.x * this.collideOffset;
        val_38.y = val_38.y * this.collideOffset;
        val_38.z = val_38.z * this.collideOffset;
        val_38.x = val_37.x + val_38.x;
        val_38.y = val_37.y + val_38.y;
        val_38.z = val_37.z + val_38.z;
        this.transform.position = new UnityEngine.Vector3() {x = val_38.x, y = val_38.y, z = val_38.z};
        UnityEngine.Vector3 val_40 = this.transform.position;
        val_53 = val_40.x;
        val_59 = val_40.z;
        val_51 = 27450992;
        UnityEngine.Vector3 val_41 = 0.normal;
        UnityEngine.Quaternion val_42 = UnityEngine.Quaternion.FromToRotation(fromDirection:  new UnityEngine.Vector3() {x = mem[536895737] + 24, y = mem[536895737] + 24 + 4, z = mem[536895737] + 32}, toDirection:  new UnityEngine.Vector3() {x = val_41.x, y = val_41.y, z = val_41.z});
        val_62 = val_42.y;
        val_61 = val_42.w;
        val_57 = UnityEngine.Object.Instantiate<System.Object>(original:  this.impactParticle, position:  new UnityEngine.Vector3() {x = val_53, y = val_40.y, z = val_59}, rotation:  new UnityEngine.Quaternion() {x = val_42.x, y = val_62, z = val_42.z, w = val_61});
        if(val_44.Length < 2)
        {
            goto label_34;
        }
        
        val_52 = 27520208;
        val_53 = 2f;
        label_42:
        if(1 >= val_44.Length)
        {
            goto label_35;
        }
        
        val_51 = this.GetComponentsInChildren<System.Object>()[1];
        if((val_51.gameObject.name.Contains(value:  -1610602255)) != false)
        {
                val_51.transform.SetParent(p:  0);
            val_51 = val_51.gameObject;
            UnityEngine.Object.Destroy(obj:  val_51, t:  val_53);
        }
        
        if((1 + 1) < val_44.Length)
        {
            goto label_42;
        }
        
        label_34:
        UnityEngine.Object.Destroy(obj:  this.projectileParticle, t:  3f);
        UnityEngine.Object.Destroy(obj:  val_57, t:  3.5f);
        UnityEngine.Object.Destroy(obj:  this.gameObject);
        return;
        label_35:
    }
    public ETFXProjectileScript()
    {
        this.colliderRadius = 1f;
        this.collideOffset = 0.15f;
    }

}
